package com.oxygen.pt.controller;

import com.oxygen.pt.pojo.dto.LoginFormDTO;
import com.oxygen.pt.pojo.dto.UserDTO;
import com.oxygen.pt.pojo.vo.Result;
import com.oxygen.pt.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.session.Session;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@CrossOrigin(origins = "*")
public class UserController {
    @Resource
    private UserService userService;

    /**
     * 用户登录请求
     * @param loginFormDTO
     * @return
     */
    @PostMapping("/login")
    Result<String> login(@RequestBody LoginFormDTO loginFormDTO){
        System.out.println("接收到的参数为 + " + loginFormDTO.toString());
        return userService.login(loginFormDTO);
    }


    /**
     * 用户注册请求
     * @param user
     * @return
     */
    @PostMapping("/add")
    public Result<String> addUser(@RequestBody UserDTO user) {
        return userService.addUser(user);
    }

    @GetMapping("hi")
    String hi(){
        return "hi";
    }
}
